<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->id();
            $table->string('security_name',255)->comment("证券名称");
            $table->string('security_code',25)->comment("证券代码");
            $table->integer('completion_date')->comment("成交日期");
            $table->char('operate',25)->comment("操作");
            $table->decimal('incurred_amount')->comment("发生金额");
            $table->decimal('current_amount')->comment("本次金额");
            $table->integer('transaction_number')->comment("买入数量");
            $table->decimal('average_amount')->comment("买入均价");
            $table->decimal('transaction_amount')->comment("买入金额");
            $table->decimal('commission_amount')->comment("手续费");
            $table->decimal('stamp_amount')->comment("印花税");
            $table->decimal('other_amount')->comment("其他杂费");
            $table->string('contract_number')->comment("合同编号");
            $table->string('deal_number')->comment("成交编号");
            $table->string('trading_market')->comment("交易市场");
            $table->date('buy_time')->comment("买入时间");
            $table->date('sell_time')->nullable()->comment("卖出时间");
            $table->integer('sell_transaction_number')->default(0)->comment("卖出数量");
            $table->decimal('sell_average_amount')->default('0.00')->comment("卖出均价");
            $table->decimal('sell_transaction_amount')->default('0.00')->comment("卖出金额");
            $table->integer('hold_day')->default(0)->comment("持股天数");
            $table->decimal('win_lose_amount')->default('0.00')->comment("盈亏金额");
            $table->tinyInteger('buy_reason')->default(1)->comment("买入原因：1三倍成交量2龙头战法");
            $table->tinyInteger('sell_reason')->default(0)->comment("卖出原因：0暂未卖出1止盈2止损3超时");
            $table->tinyInteger('status')->default(1)->comment("状态：1持有2卖出");
            $table->tinyInteger('buy_form')->default(1)->comment("买入形态：1正常2冲高回落");
            $table->string('remark',255)->nullable()->comment("备注");
            $table->tinyInteger('is_win')->default(0)->comment("是否盈利：0未知1盈利2亏损");
            $table->decimal('win_lose_percent',10,3)->comment("盈亏比例");
            $table->engine = 'InnoDB';
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
